const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}
const port = process.env.port || process.env.npm_config_port || 8080 // dev port
module.exports = {
  publicPath: '/',
  outputDir: 'dist1',
  assetsDir: 'static',
  lintOnSave: process.env.NODE_ENV === 'development',
  productionSourceMap: false,
  devServer: {
    port: port,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      '/webApi': {
        target: 'http://www.tp-masen.com/',
        changeOrigin: true,
        pathRewrite: {
          '/webApi': ''
        }
      },
      '/storage': {
        target: 'http://www.tp-masen.com/',
        changeOrigin: true,
        pathRewrite: {
          '/storage': '/storage'
        }
      }
    }
  },
  // eslink开启和关闭，即代码检测是否开启和关闭
  // lintOnSave: false,
  productionSourceMap: false,
  chainWebpack: (config) => {
    config.plugins.delete('prefetch')
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  }
}
